/**
 * Copyright (c) 2016,http://www.365wuliu.com/  All Rights Reserved.
 */
package com.cargo.base.exceptions;

import com.cargo.base.utils.JsonUtils;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/** 
 * ExceptionVo:特殊异常处理相关类
 * @Project Name:cargo 
 * @File Name:ExceptionVo.java 
 * @Package Name:com.cargo.common.exceptions
 * @Creator:wizard
 * @Date:2016年4月14日下午2:20:50 
 */
public class ExceptionVo {

	private String code;
	private String msg;
	private String redirect_code;

	private ExceptionVo() {
	}

	public ExceptionVo(Integer returncode, String code, String msg, HttpServletResponse res) {
		res.setStatus(returncode);
		ExceptionVo vo = new ExceptionVo();
		vo.setCode(code);
		vo.setMsg(msg);
		try {
			res.setContentType("text/html; charset=utf-8");
			res.setCharacterEncoding("utf-8");
			res.getWriter().print(JsonUtils.toJson(vo));
		} catch (IOException e) {
		}
	}

	public ExceptionVo(Integer returncode, String code, String msg, String redirect_code, HttpServletResponse res) {
		res.setStatus(returncode);
		ExceptionVo vo = new ExceptionVo();
		vo.setCode(code);
		vo.setMsg(msg);
		vo.setRedirect_code(redirect_code);
		try {
			res.setContentType("text/html; charset=utf-8");
			res.setCharacterEncoding("utf-8");
			res.getWriter().print(JsonUtils.toJson(vo));
		} catch (IOException e) {
		}
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public String getRedirect_code() {
		return redirect_code == null ? "" : redirect_code;
	}

	public void setRedirect_code(String redirect_code) {
		this.redirect_code = redirect_code;
	}


}
